package school.domain;

import org.springframework.security.GrantedAuthority;
import org.springframework.security.userdetails.UserDetails;

@SuppressWarnings("serial")
public abstract class SchoolUserDetails implements UserDetails {

	protected SchoolAuthority authority;
	protected String password;
	protected String username;

	public SchoolUserDetails(String auth) {
		this.authority = new SchoolAuthority(auth);
	}

	@Override
	public GrantedAuthority[] getAuthorities() {
		GrantedAuthority[] result = { authority };
		return result;
	}

	@Override
	public String getPassword() {
		return password;
	}

	@Override
	public String getUsername() {
		return username;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	public void setUsername(String username) {
		this.username = username;
	}

	@Override
	public boolean isAccountNonExpired() {
		return true;
	}

	@Override
	public boolean isAccountNonLocked() {
		return true;
	}

	@Override
	public boolean isCredentialsNonExpired() {
		return true;
	}

	@Override
	public boolean isEnabled() {
		return true;
	}

	public static class SchoolAuthority implements GrantedAuthority {
		private String authority;

		public SchoolAuthority(String authority) {
			this.authority = authority;
		}

		@Override
		public String getAuthority() {
			return authority;
		}

		@Override
		public int compareTo(Object arg0) {
			return 0;
		}

	}

}
